package com.spzx.common.core.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.spzx.common.core.context.SecurityContextHolder;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

/**
 * Package: com.spzx.common.core.config
 *
 * @author xiongkunYang
 * @description:
 * @since 2025/6/9 8:22
 */
@Component
public class MybatisMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        this.strictInsertFill(metaObject, "createBy", String.class, SecurityContextHolder.getUserName());
        this.strictInsertFill(metaObject, "updateBy", String.class, SecurityContextHolder.getUserName());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.strictUpdateFill(metaObject, "updateBy", String.class, SecurityContextHolder.getUserName());
    }
}